'''
Author: gigawing
Date: 2023-02-23 12:48:36
LastEditors: gigawing
LastEditTime: 2023-02-26 16:08:37
Description: 用于处理log文件，解析指定的指令记录，并通过选项发送
'''
import socket
import argparse
import re
from datetime import datetime
import time
import json

if __name__ == "__main__":
    sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
    try:
        valuestr = [
            {"msg":1,"mission_id":"t168111267141493","mission_name":"","mission_mode":1,"mission_experiment_mode":1},
            {"msg":5,"mission_id":"t168111267141493","missions":[]},
            {"msg":2,"mission_id":"t168111267141493","combat_units":[{"id":"AW000001","name":"-90","category":1,"team":1,"longitude":120.981927,"latitude":24.619021,"height":392.329806,"heading":-149.99671279309067,"pitch":0,"roll":0,"source":0,"life":100,"user_id":"","manufactor":"","model_number":"","type":0,"endurance":50,"detaction_range":10,"speed":50,"fpv":"","fuel":3,"BID":0,"MID":0,"ground_station_id":"AW800001","beidou_id":"AW900001","beidou_index":""}, {"id":"AH000001","name":"-16","category":1,"team":1,"longitude":0,"latitude":0,"height":0,"heading":1066,"pitch":0,"roll":0,"source":0,"life":100,"user_id":"","manufactor":"","model_number":"","type":0,"endurance":50,"detaction_range":10,"speed":50,"fpv":"","fuel":3,"BID":0,"MID":0,"ground_station_id":"AH800001","beidou_id":"AH900001","beidou_index":""}]},
            {"msg":4,"mission_id":"t168111267141493","air_lines":[{"id":"AW000002","line_id":"AW000002_lineid","delayed":0,"route_data":[["AW000002",0,0,"0",120.779246,24.254101,465,50,"","","",-0.76,"00",0,0,0,-0.12209300000000667,0],["AW000002",0,1,"0",120.758015,24.162977,327,50,"","","",-0.37,"00",0,0,10.3588,-0.300832000000014,0],["AW000002",0,2,"0",120.734446,24.086965,270,50,"","","",-0.46,"00",0,0,8.7841,0.20891699999998536,0],["AW000002",0,3,"0",120.703845,23.976225,169,50,"","","",-0.06,"00",0,0,12.6998,0.19030900000001338,0],["AW000002",0,4,"0",120.687486,23.871957,157,50,"","","",0.18,"00",0,0,11.7127,-0.09890400000000454,0],["AW000002",0,5,"0",120.66879,23.778548,191,50,"","","",0.47,"00",0,0,10.5593,-0.28090599999998744,0],["AW000002",0,6,"0",120.645521,23.650425,309,50,"","","",2.99,"00",0,0,14.4423,-0.3247119999999768,0],["AW000002",0,7,"0",120.620128,23.568064,806,50,"","","",-1.06,"00",0,0,9.5166,0.20392500000002656,0],["AW000002",0,8,"0",120.594284,23.452922,565,50,"","","",1.12,"00",0,0,13.0715,-0.44585400000005393,0],["AW000002",0,9,"0",120.568653,23.392199,707,50,"","","",0.29,"00",0,0,7.2409,-0.37356899999997495,0],["AW000002",0,10,"0",120.55235,23.331416,742,50,"","","",0,"00",0,0,6.9607,0.0816620000000512,0]]}]},
            {"msg":4,"mission_id":"t168111267141493","air_lines":[{"id":"AW000001","line_id":"AW000001_lineid","delayed":0,"route_data":[["AW000001",0,0,"0",120.779246,24.254101,465,50,"","","",-0.76,"00",0,0,0,-0.12209300000000667,0],["AW000001",0,1,"0",120.758015,24.162977,327,50,"","","",-0.37,"00",0,0,10.3588,-0.300832000000014,0],["AW000001",0,2,"0",120.734446,24.086965,270,50,"","","",-0.46,"00",0,0,8.7841,0.20891699999998536,0],["AW000001",0,3,"0",120.703845,23.976225,169,50,"","","",-0.06,"00",0,0,12.6998,0.19030900000001338,0],["AW000001",0,4,"0",120.687486,23.871957,157,50,"","","",0.18,"00",0,0,11.7127,-0.09890400000000454,0],["AW000001",0,5,"0",120.66879,23.778548,191,50,"","","",0.47,"00",0,0,10.5593,-0.28090599999998744,0],["AW000001",0,6,"0",120.645521,23.650425,309,50,"","","",2.99,"00",0,0,14.4423,-0.3247119999999768,0],["AW000001",0,7,"0",120.620128,23.568064,806,50,"","","",-1.06,"00",0,0,9.5166,0.20392500000002656,0],["AW000001",0,8,"0",120.594284,23.452922,565,50,"","","",1.12,"00",0,0,13.0715,-0.44585400000005393,0],["AW000001",0,9,"0",120.568653,23.392199,707,50,"","","",0.29,"00",0,0,7.2409,-0.37356899999997495,0],["AW000001",0,10,"0",120.55235,23.331416,742,50,"","","",0,"00",0,0,6.9607,0.0816620000000512,0]]}]},
            {"msg":4,"mission_id":"t168111267141493","air_lines":[{"id":"AH000001","line_id":"AH000001_lineid","delayed":10000,"route_data":[["AH000001",0,0,"0",120.779246,24.254101,465,50,"","","",-0.76,"00",0,0,0,-0.12209300000000667,0],["AH000001",0,1,"0",120.758015,24.162977,327,50,"","","",-0.37,"00",0,0,10.3588,-0.300832000000014,0],["AH000001",0,2,"0",120.734446,24.086965,270,50,"","","",-0.46,"00",0,0,8.7841,0.20891699999998536,0],["AH000001",0,3,"0",120.703845,23.976225,169,50,"","","",-0.06,"00",0,0,12.6998,0.19030900000001338,0],["AH000001",0,4,"0",120.687486,23.871957,157,50,"","","",0.18,"00",0,0,11.7127,-0.09890400000000454,0],["AH000001",0,5,"0",120.66879,23.778548,191,50,"","","",0.47,"00",0,0,10.5593,-0.28090599999998744,0],["AH000001",0,6,"0",120.645521,23.650425,309,50,"","","",2.99,"00",0,0,14.4423,-0.3247119999999768,0],["AH000001",0,7,"0",120.620128,23.568064,806,50,"","","",-1.06,"00",0,0,9.5166,0.20392500000002656,0],["AH000001",0,8,"0",120.594284,23.452922,565,50,"","","",1.12,"00",0,0,13.0715,-0.44585400000005393,0],["AH000001",0,9,"0",120.568653,23.392199,707,50,"","","",0.29,"00",0,0,7.2409,-0.37356899999997495,0],["AH000001",0,10,"0",120.55235,23.331416,742,50,"","","",0,"00",0,0,6.9607,0.0816620000000512,0]]}]},
            {"msg":18,"type":1,"action":1},
            {"msg":7,"mission_id":"t168111267141493","mission_action":1},
            {"msg":6,"mission_id":"t168111267141493","events":[[]]},
        ]
        for v in valuestr:
            value_str = json.dumps(v)
                
            sock.sendto(bytes(value_str,encoding='utf-8'), ("192.168.1.68",3333))


    except Exception as e:
        print(e)

    sock.close()
